package com.beemans.common.app.ui.fragments

import android.os.Bundle
import android.view.View
import com.beemans.common.app.R
import com.beemans.common.app.databinding.FragmentCustomViewBinding
import com.beemans.common.app.ui.base.BaseFragment
import com.beemans.common.ext.setPageBack
import com.tiamosu.databinding.delegate.lazyDataBinding
import com.tiamosu.databinding.page.DataBindingConfig
import com.tiamosu.fly.ext.clickNoRepeat
import com.tiamosu.navigation.ext.navigateUp

/**
 * @author tiamosu
 * @date 2021/5/28.
 */
class CustomViewFragment : BaseFragment() {
    private val dataBinding: FragmentCustomViewBinding by lazyDataBinding()

    private var title: String? = null

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.fragment_custom_view)
    }

    override fun initParameters(bundle: Bundle?) {
        title = getString(MainFragment.PARAM_TITLE)
    }

    override fun initView(rootView: View?) {
        dataBinding.viewTitleBar.setTvTitle { text = title }

        dataBinding.viewScv.setTvTitle {
            text = "标题变更"
            clickNoRepeat { showToast("点击了标题") }
        }
    }

    override fun initEvent() {
        dataBinding.viewTitleBar.setPageBack(false) {
            showToast("点击了返回按钮")
            navigateUp()
        }
        dataBinding.viewTitleBar.setTvRight {
            clickNoRepeat { showToast("点击了描述") }
        }

        dataBinding.viewScv.setViewDesc {
            clickNoRepeat { showToast("点击了描述") }
        }
    }

    override fun doBusiness() {
    }
}